package com.example.demo;

import com.juphoon.oauth.core.listener.AuthenticationListener;
import com.juphoon.oauth.core.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author rongbin.huang
 * @create 2018-06-28 下午11:20
 **/
@Slf4j
@Component
public class DemoAuthenticationListener implements AuthenticationListener {

    @Override
    public void loginSuccess(HttpServletRequest request, Object principal, String accessToken) {
        log.info("accessToken {}", accessToken);
        log.info("user {}", JsonUtils.objectToJson(principal));
    }

    @Override
    public void loginFail(HttpServletRequest request, Exception exception) {

    }

    @Override
    public void logout(HttpServletRequest request) {

    }

    @Override
    public void refreshToken(HttpServletRequest request, String accessToken) {
        log.info("==================" + accessToken);
    }
}
